package com.cosmoplat.xikai.business.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cosmoplat.xikai.business.domain.DeviceUsageRecord;
import com.cosmoplat.xikai.business.domain.dto.scada.DeviceFaultDto;
import com.cosmoplat.xikai.business.mapper.DeviceUsageRecordMapper;
import com.cosmoplat.xikai.business.service.DeviceUsageRecordService;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class DeviceUsageRecordServiceImpl extends ServiceImpl<DeviceUsageRecordMapper, DeviceUsageRecord> implements DeviceUsageRecordService {
    @Override
    public List<DeviceUsageRecord> queryForPage(DeviceFaultDto deviceFaultDto) {
        if (deviceFaultDto == null) {
            return list();
        } else {
            return list(new LambdaQueryWrapper<DeviceUsageRecord>().like(deviceFaultDto.getDeviceCode() != null, DeviceUsageRecord::getCode, deviceFaultDto.getDeviceCode()).ge(deviceFaultDto.getStartTime() != null, DeviceUsageRecord::getDataTime, deviceFaultDto.getStartTime()).le(deviceFaultDto.getEndTime() != null, DeviceUsageRecord::getDataTime, deviceFaultDto.getEndTime()).orderByDesc(DeviceUsageRecord::getDataTime));
        }


    }
}
